<?php

namespace App\Console\Commands;

use App\Jobs\SendEmailJob;
use App\Services\UserService;
use Illuminate\Console\Command;

class SendEmail extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'SendEmail';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '发送邮件任务';

    protected $userService;

    /**
     * SendEmail constructor.
     * @param UserService $userService
     */
    public function __construct(UserService $userService)
    {
        parent::__construct();

        $this->userService = $userService;
    }

    /**
     * 邮件任务
     * @return mixed
     */
    public function handle()
    {
        SendEmailJob::dispatch($this->userService->sendEmail())->onQueue('sendEmailJob');
    }
}
